

<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">

    <div class="modal-header">
        <h4 class="modal-title" id="myEntryLabel" jhiTranslate="blogApp.entry.home.createOrEditLabel">Create or edit a Entry</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                (click)="clear()">&times;</button>
    </div>
    <div class="modal-body">
        <jhi-alert-error></jhi-alert-error>
        <div class="form-group" [hidden]="!entry.id">
            <label for="id" jhiTranslate="global.field.id">ID</label>
            <input type="text" class="form-control" id="id" name="id"
                   [(ngModel)]="entry.id" readonly />
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="blogApp.entry.title" for="field_title">Title</label>
            <input type="text" class="form-control" name="title" id="field_title"
                [(ngModel)]="entry.title"
            required />
            <div [hidden]="!(editForm.controls.title?.dirty && editForm.controls.title?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.title?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="blogApp.entry.content" for="field_content">Content</label>
            <textarea class="form-control" name="content" id="field_content"
                [(ngModel)]="entry.content" required ></textarea>
            <div [hidden]="!(editForm.controls.content?.dirty && editForm.controls.content?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.content?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="blogApp.entry.date" for="field_date">Date</label>
            <div class="d-flex">
                <input id="field_date" type="datetime-local" class="form-control" name="date" [(ngModel)]="entry.date"
                required  />
            </div>
            <div [hidden]="!(editForm.controls.date?.dirty && editForm.controls.date?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.date?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
                <small class="form-text text-danger"
                    [hidden]="!editForm.controls.date?.errors?.ZonedDateTimelocal" jhiTranslate="entity.validation.ZonedDateTimelocal">
                    This field should be a date and time.
                </small>
            </div>
        </div>

        <div class="form-group">
            <label jhiTranslate="blogApp.entry.blog" for="field_blog">Blog</label>
            <select class="form-control" id="field_blog" name="blog" [(ngModel)]="entry.blog" >
                <option [ngValue]="null"></option>
                <option [ngValue]="blogOption.id === entry.blog?.id ? entry.blog : blogOption" *ngFor="let blogOption of blogs; trackBy: trackBlogById">{{blogOption.name}}</option>
            </select>
        </div>
        <div class="form-group">
            <label jhiTranslate="blogApp.entry.tag" for="field_tag">Tag</label>
            <select class="form-control" id="field_tag" multiple name="tag" [(ngModel)]="entry.tags">
                <option [ngValue]="getSelected(entry.tags, tagOption)" *ngFor="let tagOption of tags; trackBy: trackTagById">{{tagOption.name}}</option>
            </select>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" (click)="clear()">
            <span class="fa fa-ban"></span>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
        </button>
        <button type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
            <span class="fa fa-save"></span>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
        </button>
    </div>
</form>
